
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>

typedef char ElemType;

int main()
{
	char a[] = {'a', 'b', 'c', 'd', 'e'};
    ListNode *L;
    InitList(L);
    CreateListR(L, a, sizeof(a) / sizeof(a[0]));
    printf("单链表的初始元素：\n");
    OutList(L);
    printf("链表的长度为：%d\n",ListLength(L));
    if (ListEmpty(L))
        printf("链表为空\n");
    else
        printf("链表不为空\n");
	char elem;
	int position=3;
    if (GetElem(L, position, elem))
        printf("查找成功,链表第3个元素为：%c\n", elem);
    else
        printf("查找失败,链表中不存在第3个元素\n");
        
	printf("元素'a'的位置为：%d\n", LocateElem(L, 'a'));
	
	if (ListInsert(L, 4, 'f'))
    {
        printf("插入成功，插入后的链表为：\n");
        OutList(L);
    }
    else
        printf("插入失败，插入位置无效");
        
	char e;
    if (DeleteList(L, 3, e))
    {
        printf("成功删除，删除的元素为：%c\n", e);
        printf("删除后的链表为：\n");
        OutList(L);
    }
    else
        printf("删除失败,删除位置无效\n");
    
    DestoryList(L);
    return 0;
}